function selectall(formid,b){
	var oForm=E(formid);
	for (var i = 0; i < oForm.elements.length; i++) {
		if(oForm.elements[i].type=="checkbox"&&!oForm.elements[i].disabled){
			oForm.elements[i].checked = b;
		}
	}
}

function changeAction(){
	var d = E("postaction").value;
	setDisplay("movetofid",d=="movePost");
	setDisplay("stampid",d=="stampPost");
	setDisplay("highlightopt",d=="highlightPost");
}

function changeType(){
	var v = E("anc[type]").value;
	E("contentdl").style.height= v==1?"0px":"210px";
	E("urldl").style.height= v==0?"0px":"40px";
}

function ajax_doannounces(){
	popwin.loading();
	ajaxPost("anclistform","ajaxadmin.php?action=doannounces",ajax_doannounces_callback);
}


function ajax_doannounces_callback(data){
	var btns=[{value:" 确 定 ",onclick:"popwin.close();window.location.href = window.location.href",focus:true}];
	popwin.loaded();
	if(data=="y"){
		popwin.showDialog(1,"操作成功","批量操作成功",btns,280,130);
	}else{
		popwin.showDialog(0,"操作失败","操作失败:<br />"+data,btns,280,130);
	}
}

function ajax_announces(){
	Editor.attachSubmit();
	popwin.loading();
	ajaxPost("ancform","ajaxadmin.php?action=postannounces",ajax_announces_callback);
}
function ajax_announces_callback(data){
	var btns=[{value:" 确 定 ",onclick:"popwin.close();window.location.href = window.location.href",focus:true}];
	popwin.loaded();
	if(data=="y"){
		popwin.showDialog(1,"操作成功","公告发布/编辑成功",btns,280,130);
	}else{
		popwin.showDialog(0,"操作失败","操作失败:<br />"+data,btns,280,130);
	}
}


function ajax_doposts_yn(){
	if(E("postaction").value=="NOTHING"){
		var btns=[
				{value:" 确 认 ",onclick:"popwin.close()",focus:true}
		];
		popwin.showDialog(2,"提示","请选择对帖子的操作。",btns,320,130);
		return;
	}
	var btns=[
		{value:" 确 认 ",onclick:"ajax_doposts()",focus:true},
		{value:" 取 消 ",onclick:"popwin.close()"}
	];
	popwin.showDialog(3,"确认","您选择了批量操作，该操作的完成可能需要等待一些时间。<br />是否确认继续？",btns,320,130);
}

function ajax_doposts(){
	popwin.loading();
	ajaxPost("postsform","ajaxadmin.php?action=verifypost",ajax_doposts_callback);
}
function ajax_doposts_callback(data){
	var btns=[{value:" 确 定 ",onclick:"popwin.close();window.location.href = window.location.href",focus:true}];
	popwin.loaded();
	if(data=="y"){
		popwin.showDialog(1,"操作成功","批量操作成功",btns,280,130);
	}else{
		popwin.showDialog(0,"操作失败","操作失败:<br />"+data,btns,280,130);
	}
}

function ajax_clean_yn(){
	var btns=[
		{value:" 确 认 ",onclick:"ajax_clean()",focus:true},
		{value:" 取 消 ",onclick:"popwin.close()"}
	];
	popwin.showDialog(3,"确认","确认清空回收站，该操作不可恢复。<br />是否确认继续？",btns,320,130);
}

function ajax_clean(){
	popwin.loading();
	ajaxPost("topicsform","ajaxadmin.php?action=clean",ajax_clean_callback);
}
function ajax_clean_callback(data){
	var btns=[{value:" 确 定 ",onclick:"popwin.close();window.location.reload();",focus:true}];
	popwin.loaded();
	if(data=="y"){
		popwin.showDialog(1,"操作成功","成功清空回收站。",btns,280,130);
	}else{
		popwin.showDialog(0,"操作失败","操作失败:<br />"+data,btns,280,130);
	}
}

function ajax_dotopics_yn(){
	if(E("postaction").value=="NOTHING"){
		var btns=[
				{value:" 确 认 ",onclick:"popwin.close()",focus:true}
		];
		popwin.showDialog(2,"提示","请选择对帖子的操作。",btns,320,130);
		return;
	}
	var btns=[
		{value:" 确 认 ",onclick:"ajax_dotopics()",focus:true},
		{value:" 取 消 ",onclick:"popwin.close()"}
	];
	popwin.showDialog(3,"确认","您选择了批量操作，该操作的完成可能需要等待一些时间。<br />是否确认继续？",btns,320,130);
}

function ajax_dotopics(){
	popwin.loading();
	ajaxPost("topicsform","ajaxadmin.php?action=dotopics",ajax_dotopics_callback);
}
function ajax_dotopics_callback(data){
	var btns=[{value:" 确 定 ",onclick:"popwin.close();window.location.href = window.location.href",focus:true}];
	popwin.loaded();
	if(data=="y"){
		popwin.showDialog(1,"操作成功","批量操作成功",btns,280,130);
	}else{
		popwin.showDialog(0,"操作失败","操作失败:<br />"+data,btns,280,130);
	}
}


function announces_PageInit(){
	E("anc[starttime]").onfocus = function(){choosedate.dfd(E('anc[starttime]'))};
	E("anc[stoptime]").onfocus = function(){choosedate.dfd(E('anc[stoptime]'))};
	E("anc[color]").onfocus = function(event){colorpicker.choose(event)};
	E("img_color").onclick = function(event){colorpicker.choose(event)};
	if(ancid!=""){
		setSelect("anc[type]",anctype);
	}
	changeType();

	colorpicker.previewColor = function(color){
		color=color==""?"#000000":color;
		E("anc[title]").style.color = color;
		E("anc[color]").value = color;
	}
	colorpicker.chooseColor = function(color){
		color=color==""?"#000000":color;
		E("anc[title]").style.color = color;
		E("anc[color]").value = color;
	}
}

function admintopic_PageInit(){
	function colorChanged(color){
		E("highlightcolor").style.color = color;
		E("highlightcolor").value = color;		
	}
	colorpicker.previewColor = function(color){
		color=color==""?"#000000":color;
		colorChanged(color);
	}
	colorpicker.chooseColor = function(color){
		color=color==""?"#000000":color;
		colorChanged(color);
	}
}
